/**
 * 
 */
package org.codesketch.controller.common;

import org.codesketch.controller.exception.UnprocessabeEntityException;

/**
 * Evaluate preconditions on the requested objects.
 * @author quirino.brizi@gmail.com
 *
 */
public final class Preconditions {
	/**
	 * Checks the object parameter is null.
	 * @param obj the object under test.
	 * @return true if the object is null, false otherwise.
	 */
	public static <T> Boolean checkNull(T obj) {
		return null==obj;
	}
	/**
	 * Check the object parameter is null, throws {@link UnprocessabeEntityException} on the positive case.
	 * @param obj the object under test
	 * @throws UnprocessabeEntityException if the input parameter is null.
	 */
	public static <T> void checkNullThrowsUnprocessableException(T obj) {
		if(null==obj) {
			throw new UnprocessabeEntityException();
		}
	}
 }
